This invention relates to an object-oriented database system, and more particularly to a method and apparatus for virtual memory mapping and transaction management in a computer system having at least one object-oriented database.
Over the past few years, a new category of data management products has emerged. They are variously called xe2x80x9cobject-oriented database systemsxe2x80x9d, xe2x80x9cextended database systemsxe2x80x9d, or xe2x80x9cdatabase programming languagesxe2x80x9d. They are intended to be used by applications that are generally complex, data-intensive programs, which operate on structurally complex databases containing large numbers of inter-connected objects.
Inter-object references, sometimes called pointers, provide this complex structure. These programs consume time by accessing and updating objects, and following the intricate connections between objects, using both associative queries and direct traversal, performing some amount of computation as each object is visited. Typical application areas are computer-aided design, manufacturing, and engineering, software development, electronic publishing, multimedia office automation, and geographical information systems. Because of this application environment it is important for an object-oriented database system to be fast.
Often, a number of work stations or other client computers are connected to access the database in a distributed manner, normally through a server computer associated with the database. Each client computer has its own cache memory in which data required by an application program being run on the client computer are placed.
Every object-oriented database system has some way to identify an object. Current systems use a thing called an xe2x80x9cobject identifierxe2x80x9d (OID), which embodies a reference to an object. In a sense, an OID is the name of an object. An operation called xe2x80x9cdereferencingxe2x80x9d, finds an object from a given name of an object.
In most systems, object identifiers are data structures defined by software, thus dereferencing involves a software procedure, such as a conditional test to determine whether the object is already in memory, which often involves a table lookup. This software procedure generally takes at least a few instructions, and thus requires a fair amount of time. Moreover, a dereferencing step is completed for each access to the object. These operations significantly slow down processing in an application, specifically when many inter-object references are made.
Moreover, names that are commonly used for object identifiers are not in the same format that the computer hardware uses as its own virtual memory addresses. Thus, inter-object references take longer to dereference than ordinary program data. Furthermore, a software conditional check takes extra time.
Also, in current systems, data cannot remain in the client computer between transactions. Data can be cached on the client computer, but when a transaction ends, the client cache has to be discarded. Although this requirement insures consistency of data, it increases communication between the client and the server computers and fails to make use of the principles of locality which encourage the use of a cache in the first place.
A need, therefore, exists for an improved method and apparatus for facilitating dereferencing the name of an object to its corresponding object.
Another object of the invention is to name objects using the format of the computer hardware. More particularly, it is an object to provide virtual addresses as pointers to objects in the database.
Another object of the invention is to provide a hardware conditional check for determining if an object is in virtual memory in order to replace software conditional checks.
Still another object of the present invention is to minimize communication between a server computer and a client computer. More particularly, it is an object to provide a mechanism to allow a client computer to keep data in its cache between transactions and to ensure data consistency and coherency.
In accordance with the above and other objects, features and advantages of the invention, there is provided an apparatus and a method for virtual memory mapping and transaction management for an object-oriented data base system having at least one permanent storage means for storing data and at least one data base, at least cache memory for temporarily storing data addressed by physical addresses, and a processing unit including means for requesting data utilizing virtual addresses to access data in the cache memory, means for mapping virtual addresses to physical addresses and means for detecting when data requested by the requesting means is not available at the virtual address utilized. Typically, the system has a plurality of client computers each having a cache memory, interconnected by a network, and each permanent storage means has a server computer. A single computer may serve as both a client computer and a server computer.
The apparatus operates by detecting when data requested by a client computer is not available at the utilized virtual address. An application program running on a client computer may issue a command when it knows data is required, but detection preferably arises from a fault normally occuring in response to an unsuccessful data access attempt.
When the client computer detects that requested data is not available, it determines if the requested data is in the cache memory, transfers the requested data from the permanent storage means to the cache memory if the requested data is not in the cache memory, and instructs the means for mapping to map the virtual address of the requested data to the physical address of the data in the cache memory. If the requested data includes pointers containing persistent addresses, the apparatus relocates inbound the pointers in the requested data from the persistent addresses to virtual addresses.
Sometimes a virtual address that is used by an application program is not assigned to any data, and the apparatus signals an error to the means for requesting the data using that virtual address indicating that the virtual address is not valid. Otherwise the virtual address is valid, and it is determined whether the portion of the database containing the requested data has also been assigned virtual addresses. If it has not been assigned virtual addresses, such addresses are assigned to it. database portion located at a client computer is cached thereat for either read or write. When a database portion is utilized in response to a read request, it is locked for read and when used in response to a write request, it is locked for write. When the transaction commits, all locked data portions are unlocked, but can remain cached.
When a server computer receives a request for data in response to a read request, the server computer determines if any other client computer has the requested material, for example, a page or segment, encached for write. If no other client computer has the page encached for write, the page or other data section may be transferred to the requesting client computer""s cache memory. Each server preferably has an ownership table with an entry for each page of the server""s permanent storage which is encached by a client computer and indicating whether the page is encached for read or write.
The ownership table may be utilized to determine if the page is encached for write. If it is determined that a client computer has the page encached for write, the client computer is queried to determine if the page is locked for write. If the page is not locked for write, the ownership table entry for the page is downgraded from encached for write to encached for read and the transfer of the page to the requesting client computer is permitted. If the queried client computer indicates that the page is locked for write, further action is deferred until the transaction being run on the queried client computer commits. When the transaction commits, the queried client computer is downgraded to encached for read and a transfer to the queried client computer is permitted.
Each client computer preferably has a cache directory having an entry for each page in the corresponding cache memory, which entry indicates the cache state and lock state of the page. When a lock-for-write query is received at the client computer, the client computer checks its cache directory to determine if the page is locked for write. If it is determined that the page is not locked for write, the entry for the page in the cache directory is downgraded from encached for write to encached for read and a not locked response is sent to the server. If it is determined that the page is locked-for-write, the entry in the cache directory is marked xe2x80x9cdowngrade when donexe2x80x9d, the downgrading and replying to the server occurring when the transaction being run on the queried client computer commits.
When a write request is received by a server computer, the server determines if any other client computer has the page encached either for read or write and transfers the page if no other computer has the page encached. If the ownership table indicates that a client computer has the page encached, the client computers are queried to determine if the page is also locked. If a determination is made that the pages are not locked, then all entries are removed for the page from the ownership table and the requested transfer is permitted. If it is determined that the page is locked at a queried client computer, further action is deferred until transactions being run on queried client computers commit. When all transactions involving the page commit, the requested transfer is permitted. When a client computer receives a query in response to a write request, if it is determined that the page is not locked, the page is removed from the client computer cache memory and the entry for the page is removed from the cache directory. If it is determined that the page is locked, an xe2x80x9cevict when donexe2x80x9d entry is made in the cache directory for the page, the page being removed when the transaction commits.
Each segment in the database preferably contains at least one page and is divided into a data segment and an information segment. Different types of objects may be stored in a data segment with the information segment for each data segment containing a tag table having a tag entry for each object in the segment identifying the object type. A segment may also contain free space. Where objects are created during a transaction, the type for the new object is used to determine the size of the new object and the tag table is searched to find free space in a segment for the new object. A new object tag is then inserted in place of a free space tag, if suitable free space is found. A new tag is added at the end of the tag table if suitable free space is not found. Objects may also be deleted during a transaction, with the space in which such objects were stored being converted to free space when this occurs.
Each object type in a database may contain one or more pointers at selected offset locations in the object which point to persistent addresses in the database. Each database has a xe2x80x9cschemaxe2x80x9d associated therewith, the schema containing an entry for each object type present in the database. Each schema entry contains a field indicating the size of the object type and an instruction indicating the offset location in the object for each pointer for the object type. The schema is transferred to a client computer before mapping at the client computer is performed, and when data is transferred to a client computer, both the data segment and corresponding information segment are transferred.
For a preferred embodiment, relocating inbound and relocating outbound are performed utilizing the tag table to determine the object type for the selected object, and then using the object type from the tag table to obtain a description of the object from the schema. Each schema instruction for the object type is then utilized to retrieve the corresponding pointer. For relocating inbound, the persistent address of each pointer is converted to a corresponding virtual address; and for relocating outbound the virtual address of each pointer is converted to the corresponding persistent address.
Each information segment may contain a persistent relocation map (PRM) of a database, which PRM indicates the beginning persistent address for a selected page or other database portion. The PRM is transferred as part of the information segment to the client computer and is utilized to determine the persistent address corresponding to a given database, segment and offset. A virtual address map (VAM) is provided at each client computer, which map indicates the beginning virtual address for a selected database portion having a given offset. The VAM is utilized to determined the virtual address corresponding to a given database, segment and offset. When relocation inbound occurs, the PRM is utilized to determine the database, segment and offset for a given persistent page address and the VAM is then used to determine the corresponding virtual page address from the determined database segment and offset. The reverse process occurs on outbound relocation. During assignment, each PRM entry is examined in turn to determine if there is a corresponding VAM entry and a new VAM is created, and thus virtual address space is allocated for each selected database portion for which it is determined that a VAM entry does not exist.